﻿using UnityEngine;
using UnityEngine.AddressableAssets;

public class LoadPrefab : MonoBehaviour
{
    public string address;
    // Start is called before the first frame update
    void Start()
    {
        Load();
    }

    void Load()
    {
        Addressables.LoadAsset<GameObject>(address).Completed +=
            (op) =>
            {
                if (op.Status == UnityEngine.ResourceManagement.AsyncOperationStatus.Succeeded)
                {
                    Debug.Log(op.Result as GameObject);
                    var go = Instantiate(op.Result as GameObject, Vector3.zero, Quaternion.identity, transform);
                    go.transform.localPosition = Vector3.zero;
                }
            };
    }
}